package thread;

public class Demo18 {
    public static void main(String[] args) throws InterruptedException {
        Thread mainT = Thread.currentThread();
        Thread t = new Thread(()->{
            while(true){
                try {
                    System.out.println(mainT.getState());
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        //System.out.println(t.getState());
        t.start();
        //System.out.println(t.getState());
        //由于t线程是持续while，因此join不会返回
        //观察主线程状态就能看到waiting
        t.join();
        //Thread.sleep(500);
        //System.out.println(t.getState());

    }
}
